import { createRouter, createWebHashHistory } from 'vue-router'

const routes = [{
		path: '/',
		name:'',
		meta: {title: ''},
		component: () => import('../views/LockScreen.vue')
	},
	{
		path: '/desktop',
		name:'desktop',
		meta: {title: ''},
		component: () => import('../views/Desktop.vue')
	},
	{
		path: '/login',
		name:'login',
		meta: {title: '欢迎登陆'},
		component: () => import('../views/LockScreen.vue')
	},
	{
		path: '/test',
		meta: {title: ''},
		component: () => import('../views/Desktop.vue')
	}
]

const router = createRouter({
	history: createWebHashHistory(),
	routes
})

const WHITE_LIST = ['/login']

router.beforeEach((to, from, next) => {
	//console.log('===>' + JSON.stringify(to));
	if (to.meta) {
	 	document.title = to.meta.title
	}
	// let token = $store.state.session.token
	// if (token.length > 0 || WHITE_LIST.indexOf(to.path) !== -1) {
	 	next()
	// } else {
	// 	next(`/login`)
	// }
})

export default router
